package com.business.etl.flow.process;

import cn.hutool.core.util.IdUtil;
import com.business.etl.flow.status.StatusManager;
import com.google.common.graph.Graph;
import com.component.api.constants.FlowStatus;
import com.component.api.model.flow.FlowInfo;
import com.component.api.model.flow.NodeInfo;
import com.common.utils.constant.Constants;
import lombok.Data;

import java.util.concurrent.CountDownLatch;

/**
 * 描述：
 * 流程上下文
 *  避免传递参数过多
 * @author xianggj
 * @Date 2021/11/3 16:10
 **/

@Data
public class FlowContext  {

    public FlowContext(FlowInfo flowInfo) {
        this.flowInfo = flowInfo;
        this.id = IdUtil.simpleUUID();
    }

    /**
     * 唯一标识
     */
    private String id;
    /**
     * 流程对象
     */
    private FlowInfo flowInfo;
    /**
     * 记录流程状态
     */
    private FlowStatus flowStatus;

    private Graph<NodeInfo> graph;

    private ProcessHandler processHandler;

    private StatusManager statusManager;

    private CountDownLatch cdl;

    public String hashCodeStr() {
        return flowInfo.getFlowId() + Constants.INTERVAL +  id;
    }
}
